package com.example.tossednfound;

import java.util.ArrayList;

import android.test.ActivityInstrumentationTestCase2;
import android.widget.EditText;

public class JUnit extends ActivityInstrumentationTestCase2 {
	
	public JUnit() {
		super(LoginActivity.class); //class u r using
	}

	protected void setUp() throws Exception {
		super.setUp();
	}

	//test methods must start w/ "test"
	public void testCreateItem(){
		//Test if Items & Users are integrated correctly
		Item newItem0 = new Item("Santa", "Deer", 0, "02-24-2013", "Keep Sake");
		Item newItem1 = new Item("Test0", "Deer", 0, "02-24-2013", "Keep Sake");
		Item newItem2 = new Item("Santa", "Deer", 0, "02-24-2013", "Keep Sake");
		User newUser0 = new RegUser("Test0@test.com", "test0", "323 Test0 Way", "AL", 2434, "US", "Test0");
		User newUser1 = new RegUser("Test1@test.com", "test1", "323 Test1 Way", "AL", 2434, "US", "Test1");
		User newUser3 = new RegUser("Test3@test.com", "test3", "323 Test3 Way", "AL", 2434, "US", "Test3");
		ArrayList<Item> dummyItemList = new ArrayList<Item>();
		dummyItemList.add(newItem0);
		dummyItemList.add(newItem1);
		dummyItemList.add(newItem2);
		ArrayList<User> dummyUserList = new ArrayList<User>();
		dummyUserList.add(newUser0);
		dummyUserList.add(newUser1);
		dummyUserList.add(newUser3);
		boolean result0 = false;
		boolean result1 = false;
		for(Item i: dummyItemList){
			for(User u: dummyUserList){
				if(i.creator.equals(u.name))
					result0 = true;
				if(u.email.equals("fail@fail.com"))
					result1 = true;
			}
		}
		assertTrue(result0);
		assertFalse(result1);
	}
	public void testRemoveUser(){
		LoginActivity.UserList = new ArrayList<RegUser>();
		User test = new RegUser("Test0@test.com", "test0", "323 Test0 Way", "AL", 2434, "US", "Test0");
		LoginActivity.UserList.add((RegUser)test);
		assertTrue(LoginActivity.UserList.contains(test));
		assertTrue(AdminUser.removeUser(test));
		assertFalse(LoginActivity.UserList.contains(test));
	}
}
